package com.bytes32.parsing;

abstract class AbstractParser<FROM> implements Parser<FROM> {

	private int weight = 0;
	
	@Override
	public int incrementWeight() {
		return ++weight;
	}

	@Override
	public int getWeight() {
		return weight;
	}

	@Override
	public int compareTo(Parser<? super FROM> o) {
		return (-1) * (this.getWeight() - o.getWeight()); /* inverted order */
	}
	
	@Override
	public void reset() {
		this.weight = 0;
	}

	private int id = -1;
	
	@Override
	public void setId(int id) {
		this.id = id;
	}

	@Override
	public int getId() {
		return id;
	}
	
}
